<?php

namespace app\index\controller;

use think\Controller;

class Base extends Controller
{
    // 使用共享视图
    public function initialize()
    {
        $cates = model('Category')->order('sort', 'asc')->select();
        $website_info = model('System')->find();
        $article_top = model('Article')
            ->where('is_top', '1')
            ->order('create_time', 'desc')
            ->limit(5)
            ->select();
        $viewdata = [
            'websiteInfo' => $website_info,
            'cates' => $cates,
            'articleTop' => $article_top
        ];
        $this->view->share($viewdata);
    }
}
